﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        var myApp = {};
        (function (context) {
            var id = 0;

            context.next = function () {
                return id++;
            };

            context.reset = function () {
                id = 0;
            }
        })(myApp);

        window.console && console.log(
            myApp.next(),
            myApp.next(),
            myApp.reset(),
            myApp.next()
        ) //0, 1, undefined, 0

        
        /*
        var myApp = {};
        (function (context) {
            var id = 0;

            context.next = function () {
                return id++;
            };

            context.reset = function () {
                id = 0;
            }
        })(this);

        window.console && console.log(
            next(),
            next(),
            reset(),
            next()
        ) //0, 1, undefined, 0  
        */
    </script>
</head>
<body>
</body>
</html>
